package com.wyh.blog.model.dto;

import com.wyh.blog.constant.enums.ResultEnum;
import lombok.Data;

@Data
public class Result <T>{
    private ResultEnum code;
    private String msg;
    private T data;

    public static <T> Result<T> success(T data){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.SUCCESS);
        result.setMsg("成功");
        result.setData(data);
        return result;
    }

    public static <T> Result<T> fail(String msg){
        Result<T> result = new Result<>();
        result.setCode(ResultEnum.FAIL);
        result.setMsg(msg);
        return result;
    }
}
